<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Message</title>
    <script th:src="@{/js/jquery-3.1.1.min.js}"></script>
</head>
<body>
    <table border="2">
        <thead>
            <tr>
                <th>序号</th>
                <th>ID</th>
                <th>message</th>
                <th>邮箱</th>
                <th>是否处理</th>
                <th>时间</th>
            </tr>
        </thead>
        <tbody>
            <tr th:each="message, messageStat : ${messageList}">
                <td th:text="${messageStat.index}"></td>
                <td th:text="${message.id}"></td>
                <td th:text="${message.message}"></td>
                <td th:text="${message.email}"></td>
                <td th:if="${message.status == 0}"><button th:onclick="'dealMessage(\'' + ${message.id} + '\')'">更改状态</button></td>
                <td th:if="${message.status == 1}">处理了</td>
                <td th:text="${message.createDate}"></td>
            </tr>
        </tbody>
    </table>
</body>

<script th:inline="javascript">
    function dealMessage(messageId) {
        $.ajax({
            type: 'post',
            url: '/admin/ebook/message/'+messageId,
            success: function(data){
                alert(data.msg);
                window.location.href = "/admin/ebook/message";
            },
            error:function(data){
                alert("出错了！！:"+data.msg);
            }
        });
    }

    $(function () {

    })

</script>

</html>